function init() {

    $("#jqGridtable").html("");
    $("#jqGridtable").html('<table id="jqGrid"></table><div id="jqGridPager"></div>');
    $("#jqGrid").jqGrid({
        url: baseURL + 'sys/tianan/listgongshi?sea=' + $("#sea").val() + '&types=' + $("#types").val() + '&banjiestatus=' + 6 + '&manyi=' + $("#manyi").val() + '&liandept=' + $("#liandept").val(),
        datatype: "json",
        colModel: [
            {label: '提案名称', name: 'title', index: 'title', width: 80},

            {
                label: '提案类型',
                name: 'typesName',
                index: 'typesName',
                align: 'center',
                width: 40,
            },
            {label: '提案人', align: 'center', sortable: true, name: 'creatusername', index: 'dept_id', width: 40},
            {label: '办理部门', name: 'deptIdName', align: 'center', sortable: true, index: 'deptIdName', width: 40},

            {
                label: '状态', align: 'center', sortable: true, name: 'lianstatus', index: 'lianstatus', width: 40,

                formatter: function (value, row, rowObject) {
                    if (rowObject.lianstatus != 2) {
                        return lianstatus(rowObject.lianstatus);
                    } else {
                        return checkstatus(rowObject.banjiestatus);
                    }

                }
            },
            {
                label: '满意度', name: 'manyi', align: 'center', sortable: true, index: 'manyi', width: 40,
                formatter: function (value, row, rowObject) {

                    return manyistatus(rowObject.manyi);


                }
            },
            {
                label: '操作',
                name: 'id',
                align: 'center',
                index: 'id',
                width: 40,
                formatter: function (value, row, rowObject) {
                    var but = "";
                    but += ' <button type="button" class="layui-btn layui-btn-xs layui-btn-normal" onclick="info(' + value + ')">详情</button>';

                    return but;
                }
            }


        ],
        viewrecords: true,
        height: 450,
        rowNum: 10,
        rowList: [10, 30, 50],
        rownumbers: true,
        rownumWidth: 25,
        autowidth: true,
        multiselect: true,
        pager: "#jqGridPager",
        jsonReader: {
            root: "page.list",
            page: "page.currPage",
            total: "page.totalPage",
            records: "page.totalCount"
        },
        prmNames: {
            page: "page",
            rows: "limit",
            order: "order"
        },
        gridComplete: function () {
            //隐藏grid底部滚动条
            $("#jqGrid").closest(".ui-jqgrid-bdiv").css({"overflow-x": "hidden"});
        }
    });
}

$(function () {
    init();
    $('.selectpicker').selectpicker({
        width: '160px'
    });
    $('.selectpicker').selectpicker("");
    // $(".titleyear").html(new Date.getFullYear() + "提案公示")
    $(".titleyear").html( "提案公示")
});

var vm = new Vue({
    el: '#rrapp',
    data: {
        showList: true,
        title: null,
        deptlist: getDeptAll(''),
        dictlist: getDict('tiantype'),
        tiananShenyi: {},
        tianan: {}
    },
    methods: {
        query: function () {
            vm.reload();
        },
        add: function () {
            vm.showList = false;
            vm.title = "新增";
            vm.tiananShenyi = {};
        },
        update: function (event) {
            var id = getSelectedRow();
            if (id == null) {
                return;
            }
            vm.showList = false;
            vm.title = "修改";

            vm.getInfo(id)
        },
        saveOrUpdate: function (event) {
            $('#btnSaveOrUpdate').button('loading').delay(1000).queue(function () {
                var url = vm.tiananShenyi.id == null ? "sys/tiananshenyi/save" : "sys/tiananshenyi/update";
                $.ajax({
                    type: "POST",
                    url: baseURL + url,
                    contentType: "application/json",
                    data: JSON.stringify(vm.tiananShenyi),
                    success: function (r) {
                        if (r.code === 0) {
                            layer.msg("操作成功", {icon: 1});
                            vm.reload();
                            $('#btnSaveOrUpdate').button('reset');
                            $('#btnSaveOrUpdate').dequeue();
                        } else {
                            layer.alert(r.msg);
                            $('#btnSaveOrUpdate').button('reset');
                            $('#btnSaveOrUpdate').dequeue();
                        }
                    }
                });
            });
        },
        del: function (event) {
            var ids = getSelectedRows();
            if (ids == null) {
                return;
            }
            var lock = false;
            layer.confirm('确定要删除选中的记录？', {
                btn: ['确定', '取消'] //按钮
            }, function () {
                if (!lock) {
                    lock = true;
                    $.ajax({
                        type: "POST",
                        url: baseURL + "sys/tiananshenyi/delete",
                        contentType: "application/json",
                        data: JSON.stringify(ids),
                        success: function (r) {
                            if (r.code == 0) {
                                layer.msg("操作成功", {icon: 1});
                                $("#jqGrid").trigger("reloadGrid");
                            } else {
                                layer.alert(r.msg);
                            }
                        }
                    });
                }
            }, function () {
            });
        },
        getInfo: function (id) {
            $.get(baseURL + "sys/tiananshenyi/info/" + id, function (r) {
                vm.tiananShenyi = r.tiananShenyi;
            });
        },
        gettiananInfo: function (id) {

        },
        reload: function (event) {
            vm.showList = true;
            var page = $("#jqGrid").jqGrid('getGridParam', 'page');
            $("#jqGrid").jqGrid('setGridParam', {
                page: page
            }).trigger("reloadGrid");
        }
    }
});